package org.micro.rbac.core.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.micro.rbac.util.AppUtil;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicLong;

/**
 * 自定义雪花ID,15位
 *
 * @author hongsir
 * {@code createOn} 2023-03-22 12:02
 **/
@Component
public class MybatisIdGenerator implements IdentifierGenerator {

    @Override
    public Number nextId(Object entity) {
        return new AtomicLong(AppUtil.newId());
    }

}
